home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000122_icon-group-sender _Fri Nov 14 10:46:45 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id KAA10976
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Fri, 14 Nov 1997 10:46:45 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA09772; Fri, 14 Nov 1997 10:46:44 -0700
To: icon-group@optima.CS.Arizona.EDU
Date: 13 Nov 1997 13:08:13 GMT
From: eddie@holyrood.ed.ac.uk (Eddie Corns)
Message-Id: <64eu3t$c7l@scotsman.ed.ac.uk>
Organization: Edinburgh University
Sender: icon-group-request@optima.CS.Arizona.EDU
References: <Pine.LNX.3.95.971110105527.10736A-100000@uther.cs.engr.uky.edu>
Subject: Re: Regular Expressions (+ description of useful prog)
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Chris Lusena <lusena@cs.uky.edu> writes:
>For part of a class project I need/like to be able to find all
>occanses of a Regular Expression in a ASCII file. Icon seams that is might
>be good for this, since one can fine all occurance of a word easly.
>So how would one go about this? I'd like to be able to serach for the Reg.
>Exp. over line breaks if possable.
It's not clear whether you're looking to write a program or maybe you're just
saddled with a deficient machine that doesn't have the grep program. Or
perhaps you're not aware that regular expression matching is an order of
magnitude or two more complex than a straightforward search! There is
certainly a regular expression library in the icon library (regexp.icn).
However, to make it work across lines you'd need to read the entire file into
a string then call ReFind(). Using the default pattern matching rule of
leftmost longest match however this can be excrutiatingly slow. Regexp.icn
does have a way of doing shortest first which speeds things up considerably
and would probably be essential.
As an alternative you (and others reading this group) may want to look at a
program called cgrep which I came across some time ago. Look at
ftp://plg.uwaterloo.ca/pub/mt/cgrep for details. There is a report.ps which
describes the problems fairly well and a c program which ought to compile on
most platforms. This program does shortest first matching as well as allowing
you to define boundary conditions (using regular expressions) which makes
searching structured files a breeze.
Eddie